<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
	
	function selectAll() {
		$.ajax({
			url : "borrow/list",
			type : "get",
			dataType : "json",
			success : function(result) {
				//alert(result)
				
				 $(result).each(
						function (i, values) {
	                        $("#booklist").append(
	                            "<tr><td>"+values.brid+"</td>"
	                            +"<td>"+values.book.bname+"</td>"
	                            +"<td>"+values.brdate+"</td>"
	                            +"<td>"+values.flag+"</td>"
								+"<td><a href='javascript:re("+values.book.bid+")'>归还</a></td></tr>"
								
								
						)
					}
				); 
		
		}
	});
					
	}
	$(function() {
		selectAll();
		
	})
	function re(bid){
		  
		  var fbid=bid;
		  
		  //alert(fbid);
		   $.ajax({
				url:"borrow/return",
				type:"post",
				data:{
					"bid":fbid,
				},
				success:function(result){
					alert(result);
					//selectAll();
					window.location.reload();
				} 
	  }); 
	}
</script>
<title>Insert title here</title>
</head>
<body>

<table class="table table-bordered table-hover table-condensed">
	<thead>
		  <tr>
			<th>借阅编号</th>
			<th>书名</th>
			<th>借阅时间</th>
			<th>状态</th>
			<th>操作</th>
			
		</tr>
	</thead>
	<tbody id="booklist"></tbody>
</table>
</body>
</html>